﻿// Author: Jin Qing (http://blog.csdn.net/jq0123)

#include "server_type.h"

#include "log.h"

namespace ServerType
{

	std::string GetName(EServerType eServerType)
	{
		switch (eServerType)
		{
		case SERVER_BASE:
			return "base";
		case SERVER_CELL:
			return "cell";
		case SERVER_MANAGER:
			return "manager";
		case SERVER_MANAGER_SLAVERY:
			return "manager_slavery";
		}

		return "";
	}

	EServerType GetType(const std::string& strServerType)
	{
		if (strServerType.compare("manager") == 0)
		{
			return SERVER_MANAGER;
		}
		else if (strServerType.compare("manager_slavery") == 0)
		{
			return SERVER_MANAGER_SLAVERY;
		}
		
		else if (strServerType.compare("base") == 0)
		{
			return SERVER_BASE;
		}
		else if (strServerType.compare("cell") == 0)
		{
			return SERVER_CELL;
		}
		else if (strServerType.compare("voice") == 0)
		{
			return SERVER_VOICE;
		}
		LOG_ERROR_TO("ServerType.GetType", "Unknown server type: " << strServerType);
		throw (Fmt("Unknown server type: %s") % strServerType).str();
		return SERVER_NONE;
	}

}  // namespace ServerType
